
<script type="text/javascript">

    $.validator.setDefaults({
        submitHandler: function() {
            $.post("<?= site_url() ?>setup/insert_messenger_list", {
                messengername: $('#messengername').val(),
                messengerphone: $('#messengerphone').val(),
                messengerstatus: $('#messengerstatus').val()
            },
            function(data) {
                window.location = '<?php echo base_url(); ?>setup/messenger';
            });
        }
    });
    $(document).ready(function() {

        $("#formarea").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $.validator.setDefaults({
                    submitHandler: function() {
                        $.post("<?= site_url() ?>setup/insert_messenger_list", {
                            messengername: $('#messengername').val(),
                            messengerphone: $('#messengerphone').val(),
                            messengerstatus: $('#messengerstatus').val()
                        },
                        function(data) {
                            window.location = '<?php echo base_url(); ?>setup/messenger';
                        });
                    }
                });
            }
        });

        $("#formmessenger").validate();
    });

    function cancel() {
        window.location = '<?php echo base_url(); ?>setup/messenger';
    }

</script>

<form class="form-horizontal" id="formmessenger" role="form" method="post" action="#">
    <div class="col-md-offset-1">
        <div class="col-md-11">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title"><b class="caret"></b><b> Form - Add Messenger</b></h4>
                </div>
                <div class="panel-body">	

                    <div class="col-sm-9">
                        <div class="col-sm-4"><label for="messengername" class="control-label">Messenger Name<span style="color:red;">*</span></label></div>
                        <div class="col-sm-6">
                            <input type="text" class="form-control input-sm required special" id="messengername" name="messengername" maxlength="50"/>
                        </div>
                    </div>

                    <div class="col-sm-12" style="padding-bottom: 5px;">
                        <div class="col-sm-4">
                            &nbsp;
                        </div>
                    </div>

                    <div class="col-sm-9">
                        <div class="col-sm-4"><label for="messengerphone" class="control-label">Messenger Phone<span style="color:red;">*</span></label></div>
                        <div class="col-sm-6">
                            <input type="text" class="form-control input-sm required number" id="messengerphone" name="messengerphone" maxlength="15"/>
                        </div>
                    </div>

                    <div class="col-sm-12" style="padding-bottom: 5px;">
                        <div class="col-sm-4">
                            &nbsp;
                        </div>
                    </div>

                    <div class="col-sm-9">
                        <div class="col-sm-4"><label for="messengerstatus" class="control-label">Messenger Status<span style="color:red;">*</span></label></div>
                        <div class="col-sm-6">
                            <select name="messengerstatus" id="messengerstatus" class="form-control required" style="width: 140px;">
                                <option value="">-- select --</option>
                                <option value="Y">Active</option>
                                <option value="N">Non Active</option>
                            </select>
                        </div>
                    </div>

                    <div class="col-sm-12" style="padding-bottom: 0px;">
                        <div class="col-sm-4">
                            &nbsp;
                        </div>
                    </div>
                    <div class="col-sm-9">
                        <div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div>
                        <div class="col-sm-4">
                            <button type="submit" class="btn btn-success btn-block">Save</button>
                        </div>
                        <div class="col-sm-4">
                            <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                        </div>
                    </div>		
                </div>
            </div>
        </div>
    </div>
</form>	

<div style="margin-top:0px;"></div>

